package com.heima.admin.controller.v1;

import com.heima.admin.service.ChannelService;
import com.heima.model.admin.dtos.ChannerDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {
    @Autowired
    ChannelService channelService;


    //根据名称跟状态分页查询频道信息

    @ApiOperation("查询频道列表数据")
    @PostMapping("/list")
    public ResponseResult findChannelByName(@RequestBody ChannerDto channerDto){
        return channelService.getChannelListByName(channerDto);
    }

//    保存频道数据
    @ApiOperation("保存频道列表")
    @PostMapping("save")
    public ResponseResult save(@RequestBody AdChannel channel){
        return channelService.saveChannel(channel);
    }


//    根据id修改频道数据
    @ApiOperation("根据id修改频道数据")
    @PostMapping("/update")
    public ResponseResult updateByid(@RequestBody AdChannel channel){
        return channelService.updateByidAndName(channel);
    }


    @ApiOperation("根据频道ID删除")
    @GetMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return channelService.deleteByid(id);
    }

}


